package com.example.base_mvvm.entity;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class PushEntity {

    private int code;
    private DataBean data;
    private String message;

    public static PushEntity objectFromData(String str) {

        return new Gson().fromJson(str, PushEntity.class);
    }

    public static PushEntity objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), PushEntity.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<PushEntity> arrayPushEntityFromData(String str) {

        Type listType = new TypeToken<ArrayList<PushEntity>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<PushEntity> arrayPushEntityFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<PushEntity>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static class DataBean {
        private String url_play_acc;
        private String url_play_flv;
        private String url_play_hls;
        private String url_play_leb;
        private String url_play_rtmp;
        private String url_push;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public String getUrl_play_acc() {
            return url_play_acc;
        }

        public void setUrl_play_acc(String url_play_acc) {
            this.url_play_acc = url_play_acc;
        }

        public String getUrl_play_flv() {
            return url_play_flv;
        }

        public void setUrl_play_flv(String url_play_flv) {
            this.url_play_flv = url_play_flv;
        }

        public String getUrl_play_hls() {
            return url_play_hls;
        }

        public void setUrl_play_hls(String url_play_hls) {
            this.url_play_hls = url_play_hls;
        }

        public String getUrl_play_leb() {
            return url_play_leb;
        }

        public void setUrl_play_leb(String url_play_leb) {
            this.url_play_leb = url_play_leb;
        }

        public String getUrl_play_rtmp() {
            return url_play_rtmp;
        }

        public void setUrl_play_rtmp(String url_play_rtmp) {
            this.url_play_rtmp = url_play_rtmp;
        }

        public String getUrl_push() {
            return url_push;
        }

        public void setUrl_push(String url_push) {
            this.url_push = url_push;
        }

        @Override
        public String toString() {
            return "DataBean{" +
                    "url_play_acc='" + url_play_acc + '\'' +
                    ", url_play_flv='" + url_play_flv + '\'' +
                    ", url_play_hls='" + url_play_hls + '\'' +
                    ", url_play_leb='" + url_play_leb + '\'' +
                    ", url_play_rtmp='" + url_play_rtmp + '\'' +
                    ", url_push='" + url_push + '\'' +
                    '}';
        }
    }

}
